package rhc.taskSchedule.commander.callback;

import rhc.discribute.node.host.Host;
import rhc.discribute.signal.signalInterface.ReceiveMsgSignal;
import rhc.taskSchedule.BasicComponent;
import rhc.taskSchedule.command.CommandExecuter;

/**收到消息信号
 * @author rhc
 *
 */
public class ReceiveMessageSignal extends BasicComponent implements ReceiveMsgSignal {

	/**
	 * 命令发送或执行器
	 */
	private CommandExecuter commandExecuter;
	
	public ReceiveMessageSignal(CommandExecuter commandExecuter){
		this.commandExecuter=commandExecuter;
	}
	
	@Override
	public void process(Host host, String message) {
		try {
			commandExecuter.executeCommand(message, host);
		} catch (Exception e) {
			logger.error("从 "+host+" 收到命令 "+message+" 执行出错，"+e.getMessage());
			e.printStackTrace();
		}
	}

}
